using System;
using System.Collections.Generic;
using System.Text;
using WCFFactoryCaching.Common;
using System.ServiceModel;

namespace WCFFactoryCaching.Server
{
	[ServiceBehavior(IncludeExceptionDetailInFaults=true)]
	class Service : IService1
	{
		#region IService1 Members

		bool throwException = true;
		public string MyOperation1(string arg1, int arg2)
		{
			if ( arg2 == 0 )
				return "{SrvTime:" + DateTime.Now.ToString("HH:MM:ss:ffff") + "}";
			else if (arg2 == 1)
				throw new FaultException<InvalidOperationException>(new InvalidOperationException("exception"));
			else
				throw new InvalidOperationException("exception");
			//throwException = !throwException;
			//if (throwException)	// make sure every second call fails
			//    throw new FaultException<InvalidOperationException>(new InvalidOperationException("exception"));

			//return "{SrvTime:" + DateTime.Now.ToString("HH:MM:ss:ffff") + "}";
		}

		public void MyOperation2(string value)
		{
			// simply do nothing
			Console.WriteLine("Got the value '" + value + "', doing something with it...");
		}

		#endregion
	}
}
